package br.pucrs.lognplay.faces.bean;

import java.util.List;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import br.pucrs.lognplay.entity.Client;
import br.pucrs.lognplay.service.ClientManagementService;

@ManagedBean
@RequestScoped
public class ClientListBean extends Bean {

	private List<Client> clients;

	@EJB
	private ClientManagementService clientManagementService;

	public List<Client> getClients() {
		try {
			if (clients == null) {
				clients = clientManagementService.listAllClients();
			}

			return clients;
		} catch (Exception e) {
			throw new BeanException("Unexpected error", e);
		}
	}
}
